<?php
require_once (realpath(DOCUMENT_ROOT) . PROJECT_BASE . TILEPATH . 'Tile.php');

class TileFactory
{
    public static function factory($type) {
        // assumes the use of an autoloader
        $factoryProduct = $type . "Tile";
        require_once(realpath(DOCUMENT_ROOT) . PROJECT_BASE . TILEPATH . $factoryProduct . ".php");

        if (class_exists($factoryProduct)) {
            return new $factoryProduct();
        } else {
            throw new Exception("Invalid product type given.");
        }
    }
}